import request from "@/network/index";

/**
 * 获取文章分类统计
 * @param userId {string | number}
 * @returns {Promise}
 */
export function getArticleClassify(userId) {
  return request({
    url: "/article/classify",
    params: {
      userId
    }
  })
}

/**
 * 按分类id获取文章列表
 * @param classifyId {string | number}
 * @param userId {string | number}
 * @returns {Promise}
 */
export function getArticleListByClassifyId(classifyId, userId) {
  return request({
    url: `/article/classify/${classifyId}`,
    params: {
      userId
    }
  })
}


/**
 * 新建一个归档
 * @param classify {string}
 * @returns {Promise}
 */
export function createClassify(classify) {
  return request({
    url: "/article/classify",
    method: "POST",
    data: {
      classify
    }
  })
}

/**
 * 修改归档分类
 * @param classifyId {string | number}
 * @param classify {string | number}
 * @returns {Promise}
 */
export function updateClassify(classifyId, classify) {
  return request({
    url: "/article/classify",
    method: "PATCH",
    data: {
      classifyId,
      classify
    }
  })
}

/**
 * 删除一个归档
 * @param classifyId {string | number}
 * @returns {Promise}
 */
export function deleteClassify(classifyId) {
  return request({
    url: `/article/classify/${classifyId}`,
    method: "DELETE"
  })
}
